home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / e / speedtests / allocmany.e < prev    next >
Text File  |  1999-06-14  |  1KB  |  46 lines

  1. MODULE '*testspeed'
  2. MODULE 'exec/memory'
  3.  
  4. CONST LOTS_OF_TIMES=100,ALLOC_COUNT=1000,ALLOC_SIZE=2048
  5.  
  6. DEF pool
  7.  
  8. PROC main()
  9.   DEF mem
  10.   pool:=CreatePool(MEMF_ANY,ALLOC_COUNT*ALLOC_SIZE+1024,4*ALLOC_SIZE)
  11.   mem:=AllocPooled(pool,100)
  12.   test({allocmem},     'AllocMem() and FreeMem()',       LOTS_OF_TIMES)
  13.   test({allocpooled},  'AllocPooled() and FreePooled()', LOTS_OF_TIMES)
  14.   test({allocpooled2}, 'AllocPooled() and DeletePool()', LOTS_OF_TIMES)
  15.   test({fastnew},      'FastNew() and FastDispose()   ', LOTS_OF_TIMES)
  16.   FreePooled(pool,mem,100)
  17.   DeletePool(pool)
  18. ENDPROC
  19.  
  20. PROC fastnew()
  21.   DEF i,alloctab[ALLOC_COUNT]:ARRAY OF LONG
  22.   FOR i:=0 TO ALLOC_COUNT-1 DO alloctab[i]:=FastNew(ALLOC_SIZE)
  23.   FOR i:=0 TO ALLOC_COUNT-1 DO FastDispose(alloctab[i],ALLOC_SIZE)
  24. ENDPROC
  25.  
  26. PROC allocmem()
  27.   DEF i,alloctab[ALLOC_COUNT]:ARRAY OF LONG
  28.   FOR i:=0 TO ALLOC_COUNT-1 DO alloctab[i]:=AllocMem(ALLOC_SIZE,MEMF_ANY)
  29.   FOR i:=0 TO ALLOC_COUNT-1 DO FreeMem(alloctab[i],ALLOC_SIZE)
  30. ENDPROC
  31.  
  32. PROC allocpooled()
  33.   DEF i,alloctab[ALLOC_COUNT]:ARRAY OF LONG
  34.   FOR i:=0 TO ALLOC_COUNT-1 DO alloctab[i]:=AllocPooled(pool,ALLOC_SIZE)
  35.   FOR i:=0 TO ALLOC_COUNT-1 DO FreePooled(pool,alloctab[i],ALLOC_SIZE)
  36. ENDPROC
  37.  
  38. PROC allocpooled2()
  39.   DEF i,mypool,alloctab[ALLOC_COUNT]:ARRAY OF LONG
  40.   mypool:=CreatePool(MEMF_ANY,ALLOC_COUNT*ALLOC_SIZE+1024,4*ALLOC_SIZE)
  41.   FOR i:=0 TO ALLOC_COUNT-1 DO alloctab[i]:=AllocPooled(mypool,ALLOC_SIZE)
  42.   DeletePool(mypool)
  43. ENDPROC
  44.  
  45.  
  46.